package com.cxmx.escort.aspect.factory;

import com.cxmx.escort.aspect.api.AbstractApiGrpcFactory;
import com.cxmx.escort.aspect.baseApi.ApiGrpc;
import com.cxmx.escort.aspect.baseApi.Request;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

public class ApiGrpcFactory implements AbstractApiGrpcFactory {

    @Override
    public ApiGrpc.ApiBlockingStub createApiBlockingStub(ManagedChannel channel) {
        return ApiGrpc.newBlockingStub(channel);
    }

    @Override
    public ApiGrpc.ApiStub createApiStub(ManagedChannel channel) {
        return ApiGrpc.newStub(channel);
    }

    @Override
    public ManagedChannel createManagedChannel(String host, int port) {
        return ManagedChannelBuilder.forAddress(host, port).usePlaintext().build();
    }

    @Override
    public Request.Builder createRequestBuilder() {
        return Request.newBuilder();
    }

}
